home *** CD-ROM | disk | FTP | other *** search
/ Corel Draw! Unleashed / Corel Draw! Unleashed.iso / utils / inspro2 / samples / instlib.pas < prev   
Encoding:
Pascal/Delphi Source File  |  1992-12-14  |  15.5 KB  |  309 lines

  1. Library InstLib;
  2.  
  3. {$D INSTLIB.DLL - ⌐ Copyright 1992 Robert Salesas, All Rights Reserved.}
  4. {$I-}
  5. {$M 1024,1024
  6. {
  7. ********************************************************************
  8. *            EDI Install Pro & EDI UnInstall for Windows           *
  9. *                      Demo custom library                         *
  10. ********************************************************************
  11. *       Copyright 1992 Robert Salesas, All Rights Reserved         *
  12. ********************************************************************
  13. *      Version: 1.00             Author:  Robert Salesas           *
  14. *      Date:    13-Apr-1992      Changes: Original                 *
  15. *                                                                  *
  16. ********************************************************************
  17. }
  18.  
  19.  
  20. Uses WinTypes, WinProcs;
  21.  
  22.  
  23.  
  24. Const { Procedure call codes }
  25.   icm_Setup       = 10;         { Called before first dialog box.                }
  26.   icm_Setup2      = 20;         { Called after first dialog box.                 }
  27.   icm_Components  = 30;         { Called before components dialog box.           }
  28.   icm_Components2 = 40;         { Called after components dialog box.            }
  29.   icm_StartCopy   = 50;         { Called before files start getting copied.      }
  30.   icm_FileCopy    = 60;         { Called for each file that needs to get copied. }
  31.   icm_EndCopy     = 70;         { Called after all files have been copied.       }
  32.   icm_PMGroup     = 80;         { Called before the PM group dialog box.         }
  33.   icm_PMGroup2    = 90;         { Called after the PM group dialog box.          }
  34.   icm_ExtraStuff  = 100;        { Called once the installation is completed.     }
  35.   icm_EndDlgGood  = 110;        { Called before the last dialog box.             }
  36.   icm_EndDlgBad   = 120;        { Called before the last dialog box.             }
  37.   icm_EndInstall  = 130;        { Called before program terminates.              }
  38.  
  39.  
  40. Const
  41.   ir_Continue     = 0;          { Continue with normal execution.              }
  42.   ir_SkipSection  = 1;          { Skip this section.                           }
  43.   ir_AbortInstall = -1;         { Abort the installation with proper messages. }
  44.  
  45.  
  46.  
  47. {
  48.   Declaration:
  49.   ~~~~~~~~~~~~
  50.  
  51.   Function InstallDLLProc(Window : HWnd;  Code : Integer;  Src, Dest : PChar;
  52.                           Var Components : LongInt) : Integer;  Export;
  53.  
  54.   Description:
  55.   ~~~~~~~~~~~~
  56.  
  57.   Allows custom modification of the installation.  You may use or change the values
  58.   passed to your function.  By creating routines to handle special parts of your
  59.   installation (such as extra setup information or copying specially encoded files),
  60.   you can completely customize EDI Install Pro without having to write your own
  61.   installer.  There's very little (if anything) that can't be handled through a
  62.   custom DLL.  Since the DLL can be written in almost any language, you don't have
  63.   to learn to program in some strange "installer" language.
  64.  
  65.   To add a DLL to an installation script simply add the following under the [APPLICATION]
  66.   section, if it's not compressed:
  67.  
  68.       [APPLICATION]
  69.       Install DLL=INSTLIB.DLL N
  70.  
  71.   and if it is:
  72.  
  73.       [APPLICATION]
  74.       Install DLL=INSTLIB.DL$ Y
  75.  
  76.  
  77.   Parameters:
  78.   ~~~~~~~~~~~
  79.  
  80.   Window       The Window handle of the main installer window.  This will be either a bitmap,
  81.                a dithered display, or an invisible top level window.  Use this as the parent
  82.                of all your custom dialogs..
  83.  
  84.  
  85.   Code          Specifies when the procedure is getting called.  Each code allows you to
  86.                 perform certain actions.  Note that you don't have to handle every code, only
  87.                 the ones you want.  Simply return ir_Continue for any code you don't want to
  88.                 handle.
  89.  
  90.  
  91.                 icm_Setup           Src and Dest contain the default values for the
  92.                                     directories. Components are all turned on.
  93.  
  94.                                     You may modify the default values of Src and Dest.
  95.                                     Override (return ir_SkipSection) this section if you want
  96.                                     to include your own "Get destination" dialog box.
  97.  
  98.  
  99.                 icm_Setup2          Dest contains the value entered by the user.  Src and
  100.                                     Components are unchanged.
  101.  
  102.                                     You may modify the value of Dest that the user entered.
  103.                                     If you require extra setup information from the user, this
  104.                                     is the place to get it.  Pop up whatever dialogs you need.
  105.                                     You can store the information in the DLL, since it will
  106.                                     always be accessed by only one instance.
  107.  
  108.  
  109.                 icm_Components      Src, Dest and Components are unchanged.
  110.  
  111.                                     Override this section if you want to include your own
  112.                                     "Select Components" dialog box, or if you want to "force"
  113.                                     component selection.  For example you might want to use a
  114.                                     simple dialog box with radio buttons instead of the listbox.
  115.  
  116.  
  117.                 icm_Components2     Components contains the value selected by the user.
  118.                                     Src and Dest are unchanged.
  119.  
  120.                                     You may modify the value of Components that the user
  121.                                     entered.  If you require extra component or setup
  122.                                     information from the user, this is the place to get it.
  123.                                     Pop up whatever dialogs you need.  You can store the
  124.                                     information in the DLL, since it will always be
  125.                                     accessed by only one instance.
  126.  
  127.  
  128.                 icm_StartCopy       Src, Dest and Components are unchanged.
  129.  
  130.                                     This call is made before any files get copied.  Use this
  131.                                     call for any setup procedure you need if you use
  132.                                     icm_FileCopy.  For example, if you wanted to display
  133.                                     small messages on a separate as files get copied, you
  134.                                     would open the window in this call.
  135.  
  136.  
  137.                 icm_FileCopy        Src and Dest contain the SOURCE FILE PATH and the
  138.                                     DESTINATION FILE PATH.  This differs from all the other
  139.                                     calls.  Note the file name of Src and Dest might not
  140.                                     be the same.  For example, a compressed file could be
  141.                                     named FILE.EX$ as the source, and FILE.EXE as the
  142.                                     destination.  Components are unchanged.
  143.  
  144.                                     This call is made every time a file is about to be
  145.                                     copied.  Override this section if you want to display
  146.                                     messages in a window created by icm_startCopy or if you
  147.                                     want to use your own copying code.  For example, if you
  148.                                     encode your main .EXE, but not the rest of the files,
  149.                                     you can check to see if the current file is encoded, and
  150.                                     if it is, you decode it (and copy) and return
  151.                                     ir_SkipSection, and if it isn't encoded you ignore it and
  152.                                     return ir_Continue.  You can even do this:  decode the
  153.                                     source file to a temporary file (in Windows temp directory),
  154.                                     change Src to reflect this new source file, and return
  155.                                     ir_Continue.  EDI Install will then copy (decompressing if
  156.                                     needed) the file!  So you can have encoding without losing
  157.                                     the built-in compression!  This is also a good place to
  158.                                     add special version checking code if the default mechanisms
  159.                                     are not sufficient.  If you return ir_AbortInstall, you
  160.                                     should also display an error dialog box.
  161.  
  162.  
  163.                 icm_EndCopy         Src, Dest and Components are unchanged.
  164.  
  165.                                     This call is made after any files get copied.  Use this
  166.                                     call to clean up the setup procedure you accessed in
  167.                                     icm_StartCopy.
  168.  
  169.  
  170.                 icm_PMGroup         Src contains the default name for the Program Manager
  171.                                     group.  Dest and Components are unchanged.
  172.  
  173.                                     This call is made before the PM Group dialog box is
  174.                                     displayed.  You may override it with your own dialog box
  175.                                     if you don't like the default dialog box.
  176.  
  177.  
  178.                 icm_PMGroup2        Src contains the user selected name for the Program
  179.                                     Manager group.  Dest and Components are unchanged.
  180.  
  181.                                     This call is made after the PM Group dialog box is
  182.                                     displayed.  You may use to add items to the user selected
  183.                                     PM group.
  184.  
  185.  
  186.                 icm_ExtraStuff      Src, Dest and Components are unchanged.
  187.  
  188.                                     This call is made once the installation has successfully
  189.                                     been completed, but before the user has been informed.  You
  190.                                     may use it if you need to take care of extra stuff such as
  191.                                     modifying the CONFIG.SYS or AUTOEXEC.BAT files.
  192.  
  193.  
  194.                 icm_EndDlgGood      Src, Dest and Components are unchanged.
  195.                 icm_EndDlgBad
  196.                                     These are called before the last dialog box ("Installation
  197.                                     complete/incomplete") is displayed.  You can override it
  198.                                     if you prefer to display your own dialog box or if you
  199.                                     need special "clean up" procedures depending on success
  200.                                     (icm_EndDlgGood) or failure (icm_EndDlgBad).  If you handle
  201.                                     the dialog, return ir_SkipSection.  If not, return
  202.                                     ir_Continue.  Note that these calls will NOT be made if
  203.                                     the installation was aborted BEFORE the file copy process
  204.                                     was started (prior to the first icm_FileCopy call).
  205.  
  206.  
  207.                 icm_EndInstall      Src, Dest and Components are unchanged.
  208.  
  209.                                     This call is made before the installer quits.  You
  210.                                     can do your general cleanup here since it will always get
  211.                                     called, regardless of the success/failure/cancelled
  212.                                     situation.  Return values are ignored.
  213.  
  214.   Src           Points to a 256 byte buffer (including NULL terminater) containing the
  215.                 source path or the source file, depending on the value of Code.  It contains
  216.                 the source file if Code is equal to icm_FileCopy, and the source path for
  217.                 everything else.  You may modify this value any time you like.  It could
  218.                 potentially be changed every time EDI Install needs a new disk, since the
  219.                 user is asked for an alternate path.
  220.  
  221.  
  222.   Dest          Points to a 256 byte buffer (including null terminater) containing the
  223.                 destination path or the destination file, depending on the value of Code.
  224.                 It contains the destination file if Code is equal to icm_FileCopy, and the
  225.                 destination path for everything else.  You may modify this value any time you
  226.                 like, although that's not a very good idea.
  227.  
  228.                 NOTE: Not used in EDI UnInstall.
  229.  
  230.  
  231.   Components    Points to a 32-Bit value (a longint or double word) representing 32 separate
  232.                 values.  Technically it's a bitpacked array of 32, bit sized elements.  So each
  233.                 bit represents a component (up to a maximum of 32 components).  If the bit is
  234.                 on, the component is selected, if it's off, it is unselected.  For example,
  235.                 to determine if a particalur component is selected or not, in Turbo Pascal you
  236.                 would do:
  237.  
  238.                     If (((1 SHL Comp) And Components) = (1 SHL MyComponent)) Then
  239.  
  240.                 Where "MyComponent" is the component you want to check for.  You may modify
  241.                 this value any time you like.
  242.  
  243.  
  244.   Returns
  245.   ~~~~~~~
  246.  
  247.   Possible return values are:
  248.  
  249.                 ir_Continue         Continues with the the installation.
  250.  
  251.                 ir_SkipSection      Skips the applicable section (icm_Setup, icm_Components,
  252.                                     icm_PMGroup, icm_EndDlgGood, icm_EndDlgBad).
  253.  
  254.                 ir_AbortInstall     Aborts the installation and displays a message box.
  255.  
  256.  
  257.  
  258.   Notes
  259.   ~~~~~
  260.  
  261.   If you need to use new dialogs, add them to the DLL, not the installer.  If you add them to
  262.   the installer you are likely to cause problems during multiple disk installations.  Also,
  263.   you should attempt to maintain the same "look and feel" through the dialogs, and use the
  264.   icons located in INSTALL.EXE whenever possible.  There aren't any restrictions on what you
  265.   can and cannot do in the DLL provided you follow standard DLL rules.  You don't need to lock
  266.   or fix the DLL since the installer will copy it to a temporary file on the hard disk.  It
  267.   will be deleted once the installation is complete.
  268.  
  269.   If there's something you want to do but you can seem to be able to with the current codes,
  270.   let us know and we'll see what we can do about.  If you aren't too sure about what you need
  271.   to do or you don't want to write the DLL yourself, we can create a custom DLL for a reasonable
  272.   fee.
  273. }
  274.  
  275.  
  276. { The following is a skeleton procedure.  Fill it in to handle your needs. }
  277.  
  278.  
  279.   Function InstallDLLProc(Window : HWnd;  Code : Integer;  Src, Dest : PChar;
  280.                           Var Components : LongInt) : Integer;  Export;
  281.   Begin
  282.     InstallDLLProc := ir_Continue;
  283.  
  284.     Case Code Of
  285.       icm_Setup       : OutputDebugString('Setup');
  286.       icm_Setup2      : OutputDebugString('Setup2');
  287.       icm_Components  : OutputDebugString('Components');
  288.       icm_Components2 : OutputDebugString('Components2');
  289.       icm_StartCopy   : OutputDebugString('StartCopy');
  290.       icm_FileCopy    : OutputDebugString(Src);
  291.       icm_EndCopy     : OutputDebugString('EndCopy');
  292.       icm_PMGroup     : OutputDebugString(Src);
  293.       icm_PMGroup2    : OutputDebugString(Src);
  294.       icm_ExtraStuff  : OutputDebugString('ExtraStuff');
  295.       icm_EndDlgGood  : OutputDebugString('EndDlgGood');
  296.       icm_EndDlgBad   : OutputDebugString('EndDlgBad');
  297.       icm_EndInstall  : OutputDebugString('EndInstall');
  298.     End;
  299.   End;
  300.  
  301.  
  302.  
  303. Exports
  304.   InstallDLLProc Index 100;
  305.  
  306.  
  307. Begin
  308. End.
  309.